const path = require('path')
const webpack = require('webpack')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const CopyPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
	entry: './src/main.js',
	output: {
		filename: '[name].bundle.js',
		path: path.join(__dirname, 'dist'),
	},
	resolve: {
		alias: {
			'@': path.join(__dirname, 'src'),
		},
	},
	optimization: {
		splitChunks: {
			chunks: 'all',
		},
	},
	plugins: [
		new VueLoaderPlugin(),
		new webpack.DefinePlugin({
			BASE_URL: '"/"',
		}),
		new CopyPlugin({
			patterns: [{ from: 'public', to: '' }],
		}),
		new HtmlWebpackPlugin({
			template: './public/index.html',
			title: 'Webpack For Vue',
		}),
	],
}
